<?php
/**
 * Created by PhpStorm.
 * User: work
 * Date: 18-8-4
 * Time: 下午5:57
 */

namespace PddWechat\Models\User\Dao;


use Dai\Framework\Base\BaseDao;
use Dai\Framework\Library\Log;
use PddWechat\Models\User\DataObject\UserInviteRecordDo;

/**
 * Class UserDao
 * @dataObject(\PddWechat\Models\User\DataObject\UserInviteRecordDo)
 * @package PddWechat\Models\User\Dao
 */
class UserInviteRecordDao extends BaseDao
{
    public function insert(UserInviteRecordDo $userInviteRecordDo)
    {
        Log::info("UserInviteRecordDao insert , data is ".var_export($userInviteRecordDo, true));
        $userInviteRecordDo->id = $this->execute("user.invite_record.insert",$userInviteRecordDo);
        return $userInviteRecordDo;
    }


    /**
     * @desc 某一个openId的邀请记录
     * @param $inviteOpenId
     * @return array|UserInviteRecordDo
     */
    public function selectOpenIdInviteRecords($inviteOpenId)
    {
        $param = [
            'inviteOpenId' => $inviteOpenId,
            'select' => '*'
        ];
        $res = $this->execute("user.invite_record.select_invite_record", $param);
        $ret = [];
        if( count($res) > 0 ) {
            foreach ($res as $t) {
                /** @var UserInviteRecordDo $ret */
                $ret[] = $this->trimBase($t);
            }
        }
        return $ret;
    }

}